﻿using System;


namespace RoughJs.Error
{
    public class RhinoException : Exception
    {
        public RhinoException() { }
        public RhinoException(String msg) : base(msg) { }

        public void recordErrorOrigin(String sourceName, int lineNumber,
                                 String lineSource, int columnNumber)
        {
            // XXX: for compatibility allow for now -1 to mean 0
            if (lineNumber == -1)
            {
                lineNumber = 0;
            }

            if (sourceName != null)
            {
                initSourceName(sourceName);
            }
            if (lineNumber != 0)
            {
                initLineNumber(lineNumber);
            }
            if (lineSource != null)
            {
                initLineSource(lineSource);
            }
            if (columnNumber != 0)
            {
                initColumnNumber(columnNumber);
            }
        }
        public void initColumnNumber(int columnNumber)
        {
            if (columnNumber <= 0) throw new ArgumentException(columnNumber.ToString());
            if (this.columnNumber1 > 0) throw new ArgumentException();
            this.columnNumber1 = columnNumber;
        }

        public void initLineSource(String lineSource)
        {
            if (lineSource == null) throw new ArgumentException();
            if (this.lineSource1 != null) throw new ArgumentException();
            this.lineSource1 = lineSource;
        }
        public void initLineNumber(int lineNumber)
        {
            if (lineNumber <= 0) throw new ArgumentException(lineNumber.ToString());
            if (this.lineNumber1 > 0) throw new ArgumentException();
            this.lineNumber1 = lineNumber;
        }
        public void initSourceName(String sourceName)
        {
            if (sourceName == null) throw new ArgumentException();
            if (this.sourceName1 != null) throw new ArgumentException();
            this.sourceName1 = sourceName;
        }



        /**
    * Returns the line number of the statement causing the error,
    * or zero if not available.
    */
        public int lineNumber()
        {
            return lineNumber1;
        }

        /**
         * The column number of the location of the error, or zero if unknown.
         */
        public int columnNumber()
        {
            return columnNumber1;
        }



        /**
         * The source text of the line causing the error, or null if unknown.
         */
        public String lineSource()
        {
            return lineSource1;
        }



        public String sourceName()
        {
            return sourceName1;
        }









        private String sourceName1;
        private int lineNumber1;
        private String lineSource1;
        private int columnNumber1;

        public Object interpreterStackInfo;
       public int[] interpreterLineData;
    }
}
